<template>
  <div class="risk">
    <eagle-tab-page-list
      url="/DangerCheckTaskDetail/GetHiddenDangerPageData"
      :params="params"
      @initActive="_initActive"
      @initList="_initList"
      ref="eagleTabPageList"
    >
      <eagle-cell class="card" v-for="(item, index) in list" :key="index">
        <template v-if="active === 0">
          <div class="warn_item">
              <div @click="goToDetail(item)">
                <div class="f14">
                  <div>
                    {{ index + 1 }}、隐患描述：{{ item.HiddenDangerDesc }}
                  </div>
                </div>

                <eagle-row gutter="20" class="dep_sort">
                  <eagle-col span="20">
                    <img
                      src="@/assets/Images/AppIcon/icon_list_area.png"
                      alt=""
                    />{{ item.HiddenDangerArea || "暂无区域" }}</eagle-col
                  >
                </eagle-row>
                <eagle-row gutter="20" class="dep_sort">
                  <eagle-col span="10">
                    <img
                      src="@/assets/Images/AppIcon/icon_list_user.png"
                      alt=""
                    />{{ item.CreateChnName }}</eagle-col
                  >
                  <eagle-col span="14">
                    <img
                      src="@/assets/Images/AppIcon/icon_list_date.png"
                      alt=""
                    />{{ getDateTime(item.CreateDate) }}</eagle-col
                  >
                </eagle-row>
              </div>
          </div>
        </template>
        <template v-else>
          <div class="warn_item">
              <div @click="goDetail(item)">
                <div class="f14">
                  <div>
                    {{ index + 1 }}、隐患描述：{{ item.HiddenDangerDesc }}
                  </div>
                </div>
                <eagle-row gutter="20" class="dep_sort">
                  <eagle-col span="20">
                    <img
                      src="@/assets/Images/AppIcon/icon_list_area.png"
                      alt=""
                    />{{ item.HiddenDangerArea || "暂无区域" }}</eagle-col
                  >
                </eagle-row>
                <eagle-row gutter="20" class="dep_sort">
                  <eagle-col span="10">
                    <img
                      src="@/assets/Images/AppIcon/icon_list_user.png"
                      alt=""
                    />{{ item.CreateChnName }}</eagle-col
                  >
                  <eagle-col span="14">
                    <img
                      src="@/assets/Images/AppIcon/icon_list_date.png"
                      alt=""
                    />{{ getDateTime(item.CreateDate) }}</eagle-col
                  >
                </eagle-row>
              </div>
              <eagle-divider/>
              <div class="dep_sort">
                <div class="fr" @click="history(item)">
                  <img src="@/assets/Images/AppIcon/icon_list_edit.png" />
                  审批历史
                </div>
              </div>
            </div>
        </template>
      </eagle-cell>
    </eagle-tab-page-list>
  </div>
</template>

<script>
import { getDateTime } from "@/utils/getDate";

export default {
  data() {
    return {
      params: [
        {
          title: "待整改",
          dataType: "ToBeCorrectived",
          badge: true,
        },
        {
          title: "已整改",
          dataType: "BeCorrectived",
          badge: false,
        },
      ],
      list: [],
      active: 0,
    };
  },
  created() {
  },
  methods: {
    _initActive(active) {
      this.active = active;
    },
    _initList(list) {
      this.list = list;
    },
    
    getDateTime(value) {
      return getDateTime(value);
    },
    history(item) {
      this.$router.push({
        path: "/Common/ApproveHistory",
        query: {
          recordID: item.ID,
          opController: "DangerCheckTaskDetail",
          operate: "corrective,formulate",
        },
      });
    },

    goDetail(item) {
      this.$router.push({
        path: "/Danger/DangerCheckDetailView",
        query: { id: item.ID,type:"correctived" },
      });
    },

    goToDetail(item) {
      this.$router.push({
        path: "/Danger/MyCorrectivedDetail",
        query: { id: item.ID },
      });
    },

    getFile(equipmentCode) {
      this.$router.push({
        path: "/Equipment/safetyfile",
        query: { equipmentCode: equipmentCode },
      });
    },
    // 编辑设备信息
    edit(equipmentCode) {
      this.$router.push({
        path: "/Equipment/Edit",
        query: { equipmentCode: equipmentCode },
      });
      this.$router.push("");
    },
    // 设备检验
    editCheck(equipmentCode) {
      this.$router.push({
        path: "/Equipment/editcheck",
        query: { equipmentCode: equipmentCode },
      });
    },
  },
};
</script>

<style lang="less" scoped>
.dep_sort {
  // display: flex;
  // flex-wrap: wrap;
  // margin-bottom: 5px;
  img {
    height: 15px;
    width: 15px;
    margin-right: 5px;
  }
}

.van-divider{
  margin-top: 5px;
  margin-bottom: 5px;
}
</style>
